CREATE TABLE [dbo].[AJUSTES_INV_DETALLES]
(
[ID] [numeric] (10, 0) NOT NULL,
[ID_PRODUCTO] [numeric] (10, 0) NOT NULL,
[COSTO] [numeric] (10, 2) NOT NULL,
[PRECIO] [numeric] (10, 2) NOT NULL,
[CANTIDAD_AJUSTADA] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_AJUSTES_INV_DETALLES_CANTIDAD_AJUSTADA] DEFAULT ((0)),
[EXISTENCIA_PREVIA] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_AJUSTES_INV_DETALLES_EXISTENCIA_PREVIA] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AJUSTES_INV_DETALLES] ADD CONSTRAINT [PK_AJUSTES_INV_DETALLES] PRIMARY KEY CLUSTERED  ([ID], [ID_PRODUCTO]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AJUSTES_INV_DETALLES] ADD CONSTRAINT [FK_AJUSTES_INV_DETALLES_AJUSTES_INV] FOREIGN KEY ([ID]) REFERENCES [dbo].[AJUSTES_INV] ([ID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[AJUSTES_INV_DETALLES] ADD CONSTRAINT [FK_AJUSTES_INV_DETALLES_PRODUCTOS] FOREIGN KEY ([ID_PRODUCTO]) REFERENCES [dbo].[PRODUCTOS] ([ID])
GO
